package com.nerrys.controller;

import com.nerrys.common.SendContent;
import com.nerrys.service.EmailService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author code-l
 * @date 2021年12月24日16:39
 */
@Controller
public class SendController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private EmailService emailService;

    @Autowired
    private SendContent sendContent;

    @RequestMapping("/sendmail")
    public String sendmail(){
        String tomail="xxx@qq.com";
        String subject="圣诞祝福邮件";
        String contents=sendContent.contents();
        emailService.sendSimpleMail(tomail,subject,contents);
        System.out.println(contents);
        logger.info("这次的话语是:"+contents);
        System.out.println("发送成功");
        return "redirect:index.html";
    }
}
